function rpc_receive() {
	document.getElementById("questions_answer").style.fontWeight = "normal";
	document.getElementById("questions_correct").style.fontWeight = "normal";
	document.getElementById("questions_rate").style.fontWeight = "normal";
	var xhr = getXmlHttpRequestObject();
	if(!xhr) {
		// TODO: No XMLHttpRequest Support - what to do?
		alert("Sorry, but the messages_sender library does not work with your browser.");
	}
	else
	{
		xhr.onreadystatechange = function()
		{
			if(xhr.readyState == 4)
			{
				if(xhr.status == 200)
				{
					// We have an event.
					var response = xhr.responseText;
					if(response == " homework_to_do")
					{
						var a = document.getElementById("questions_answer");
						var value = a.innerHTML;
						var number = value.slice(1, value.length - 1);
						var newNumber = parseInt(number, 10) + 1;
						a.innerHTML = " (" + newNumber + ")";
						a.style.fontWeight = "bold";
					}
					else if(response == " homework_to_correct")
					{
						var a = document.getElementById("questions_correct");
						var value = a.innerHTML;
						var number = value.slice(1, value.length - 1);
						var newNumber = parseInt(number, 10) + 1;
						a.innerHTML = " (" + newNumber + ")";
						a.style.fontWeight = "bold";
					}
					else if(response == " homework_to_rate")
					{
						var a = document.getElementById("questions_rate");
						var value = a.innerHTML;
						var number = value.slice(1, value.length - 1);
						var newNumber = parseInt(number, 10) + 1;
						a.innerHTML = " (" + newNumber + ")";
						a.style.fontWeight = "bold";
					}

					rpc_receive();
				}
				else
				{
					// TODO: Oops, an error retrieving the event - what to do?
					alert("Error waiting for messages_sender event");
				}
			}
		}
		xhr.open("POST", "/yaws/homework_router.yaws", true);			
		xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		xhr.send(null);
	}     
}


//Gets the browser specific XmlHttpRequest Object
function getXmlHttpRequestObject()
{
var xhr = false;
	if(window.XMLHttpRequest)
	{
		xhr = new XMLHttpRequest();
	}
	else if(window.ActiveXObject)
	{
		try {
			xhr = new ActiveXObject("Msxml2.XMLHTTP");
		} catch(e) {
			try {
			xhr = new ActiveXObject("Microsoft.XMLHTTP");
			} catch(e) {}
		}
	}
	return xhr;
}

function start()
{	rpc_receive();
}		
